package homework26;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class DataRead {
    public String read(String dataNameSrc) {
        System.out.println("读取数据，获得数据");
        StringBuffer stringBuffer = new StringBuffer();
        try{
            FileInputStream dataInputStream = new FileInputStream(dataNameSrc);
            int data ;
            while((data = dataInputStream.read())!= -1){
                stringBuffer.append((char) data);
            }
            dataInputStream.close();
            System.out.println(stringBuffer.toString());
        }
        catch (FileNotFoundException e){
            System.out.println("数据不存在，无法读取！！1");
        }
        catch (IOException e){
            System.out.println("数据错误...");
        }
        return stringBuffer.toString();
    }
}